Systems and Methods for Generating Jokes

ABSTRACT

Methods for generating jokes include coupling one or more servers with one or more databases having words stored therein; receiving text at the server(s) from an external source communicatively coupled with the server(s) through a telecommunications network; in response to receiving the text at the server(s): selecting one or more topic keywords of the topic sentence using the server(s); generating one or more punch words with the server(s) using words stored in the database related to the topic keyword(s); adding bridges to the punch word(s), using the server(s), to generate one or more jokes; communicating a signal to a first computing device through the telecommunications network using the server(s); and in response to receiving the signal at the first computing device, displaying or speaking one of the one or more jokes using the first computing device. Systems for generating jokes include networked computer components configured to carry out the methods.

CROSS REFERENCE TO RELATED APPLICATIONS

This document claims the benefit of the filing date of U.S. ProvisionalPatent Application No. 62/634,845, entitled “System and Method forGenerating Jokes,” naming as first inventor Joseph E. Toplyn, which wasfiled on Feb. 24, 2018, the disclosure of which is hereby incorporatedentirely herein by reference.

BACKGROUND 1. Technical Field

Methods and systems disclosed herein relate generally to methods andsystems for generating jokes and, more particularly, to methods andsystems for generating original, contextually integrated jokes based ontext that has been obtained from an external source.

2. Background Art

Non-computerized methods of creating monologue jokes having threecomponents, i.e., topic, angle or bridge words, and punch line, exist inthe art as discussed in, for example, Joe Toplyn, “Comedy Writing forLate-Night TV,” published by Twenty Lane Media, LLC (2014) (for examplepages 53-54, 57, 68-70, 74-77, 79, 85-86, 99-101, and 104-106 of thatpublication discuss these elements).

Computational humor is a relatively new branch of computationallinguistics and artificial intelligence (AI). One computational humorchallenge that researchers have attempted to address is using a computerto generate jokes in a more humanlike, engaging, and effective fashion.

For example, the JAPE (Joke Analysis and Production Engine) programgenerates punning riddles. STANDUP (System To Augment Non-speakers'Dialogue Using Puns) was developed as an extension to JAPE. The HAHA(Humorous Agents for Humorous Acronyms) acronym generator creates wittyacronyms. The DEVIANT (Double Entendre via Noun Transfer) program findssentences that can be turned into jokes by adding the sentence “That'swhat she said.” But those joke generation programs are limited tocertain joke formulas and formats.

The developers of AI virtual assistants like AMAZON's ALEXA, APPLE'sSIRI, MICROSOFT's CORTANA, and GOOGLE ASSISTANT sidestep the challengeof generating original jokes. Instead of ad-libbing newly created,contextually integrated jokes during their interactions with humans,those AI virtual assistants merely deliver, on request, jokes prewrittenby humans that have been stored in a database.

SUMMARY

Embodiments of systems for generating jokes may include: one or moredatabases; one or more servers communicatively coupled with one or moredatabases; and a first computing device communicatively coupled with atleast one of the one or more servers through a telecommunicationsnetwork, wherein the one or more servers are configured to receive textfrom an external source communicatively coupled with the one or moreservers through the telecommunications network and, in response, selectone or more topic keywords, generate one or more punch words using wordsstored in the one or more databases which are related to the one or moretopic keywords, use the one or more punch words to generate one or morejokes, and communicate a signal to the first computing device; andwherein the first computing device is configured to, in response toreceiving the signal, display or speak one of the one or more jokes.

Embodiments of systems for generating jokes may include one or more orall of the following:

The external source may be the first computing device.

The received text may be text typed or spoken to a virtual assistantusing the first computing device.

The external source may be a third party server and not the firstcomputing device.

The one or more servers may be further configured to select a topicsentence from the received text.

The one or more servers may be further configured to add one or morebridges to the one or more punch words to generate the one or morejokes.

The one or more servers may be further configured to determine a highestranking joke from among the one or more jokes.

Embodiments of methods for generating jokes may include: providing oneor more servers communicatively coupled with one or more databases; inresponse to receiving text, at the one or more servers through atelecommunications network or at a first computing device: selecting oneor more topic keywords from the received text using the one or moreservers or using the first computing device; generating one or morepunch words with the one or more servers using words stored in the oneor more databases which are related to the one or more topic keywords;generating one or more jokes with the one or more servers using the oneor more punch words; communicating a signal to the first computingdevice through the telecommunications network using the one or moreservers; and in response to receiving the signal at the first computingdevice, displaying or speaking one of the one or more jokes using thefirst computing device.

Embodiments of methods for generating jokes may include one or more orall of the following:

The received text may be received at the one or more servers from thefirst computing device through the telecommunications network.

The received text may be text typed or spoken to a virtual assistantusing the first computing device.

The received text may be received at the one or more servers from athird party server and not from the first computing device.

The method may further include selecting a topic sentence from thereceived text using the one or more servers or the first computingdevice.

The method may further include adding one or more bridges to the one ormore punch words, using the one or more servers, to generate the one ormore jokes.

The method may further include, using the one or more servers,determining a highest ranking joke from among the one or more jokes.

Embodiments of methods for generating jokes may include: providing oneor more servers communicatively coupled with one or more databases;receiving text at the one or more servers from an external sourcecommunicatively coupled with the one or more servers through atelecommunications network; in response to receiving the text at the oneor more servers: selecting a topic sentence from the received text usingthe one or more servers; selecting one or more topic keywords of thetopic sentence using the one or more servers; generating one or morepunch words with the one or more servers using words stored in the oneor more databases which are related to the one or more topic keywords;adding one or more bridges to the one or more punch words, using the oneor more servers, to generate one or more jokes; communicating a signalto a first computing device through the telecommunications network usingthe one or more servers; and in response to receiving the signal at thefirst computing device, displaying or speaking one of the one or morejokes using the first computing device.

Embodiments of methods for generating jokes may include one or more orall of the following:

Generating the one or more punch words may further include selecting agroup of words stored in the one or more databases which are related tothe one or more topic keywords, sorting the group of words into pairs,and calculating a wordplay score for each pair.

The method may further include, using the one or more servers,determining a highest ranking joke from among the one or more jokes, andfurther may include, in response to receiving the signal at the firstcomputing device, displaying or speaking the highest ranking joke usingthe first computing device.

The one or more topic keywords may include a first topic keyword and asecond topic keyword, and the method may further include, using the oneor more servers, determining whether the first topic keyword is a stringconsisting of two or more tokens and, if so, calculating a wordplayscore for each pairing of at least one of the two or more tokens withone of a plurality of words related to the second topic keyword.

Generating the one or more punch words may further include generating aportmanteau word using at least a portion of one of the words related tothe one or more topic keywords.

The one or more topic keywords may include a first topic keyword and asecond topic keyword, and generating the one or more punch words mayinclude selecting a word chunk which is related to the first topickeyword and replacing one or more words of the word chunk with one ormore words that are related to the second topic keyword.

Embodiments of methods for generating jokes may include: providing anelectronic device including a processor and memory storing instructionsfor execution by the processor; accepting a text string from a textinput or from a speech input received from a user or obtained fromdocuments; extracting a sentence for a joke topic from a text stringbased on features such as whether the sentence is short enough and wherethe sentence falls in the text string; via the processor, analyzing thejoke topic and identifying nouns, noun phrase chunks, named entities,and other words and phrases that are potentially the most useful forgenerating jokes; eliminating from consideration of potential use ingenerating jokes any of a plurality of text units in a list of stopwords stored in a database and text units that are too similar to eachother; determining, via the processor, which pair of words or phrases inthe topic sentence is least likely to share the same context in a large,relevant text corpus and selecting those as the topic keywords to beused for generating jokes; determining, via the processor, a pluralityof words related to the topic keywords in that they are semanticallyclose to the topic keywords in the context of a large, relevant, textcorpus; scoring wordplay based on a set of scoring rules that take intoaccount features of a pair of words including but not limited to editdistance based on pronunciation, edit distance based on spelling, numberof stop consonants based on spelling, number of stop consonants based onpronunciation, alliteration, rhyming, stemming, and lemmatization; viathe processor, pairing words related to the topic keywords with eachother and with the topic keywords themselves and determining which wordpairs have the best wordplay so as to create punch word(s) with which toend the joke; to create a joke, adding bridge words selected at randomfrom a preset list in a database to the topic keywords and the punchword(s).

Embodiments of methods for generating jokes may include one or more orall of the following:

Creating punch word(s) for a second type of joke by using wordplay topair words related to one topic keyword with a token of a second topickeyword that consists of more than one token.

Creating punch word(s) for a third type of joke by exploiting wordplayto form a portmanteau word out of a word related to one topic keywordand a word related to a second topic keyword.

Creating punch word(s) for a fourth type of joke by substituting a wordrelated to one topic keyword for one or more words with which it hasadequate wordplay that are contained in a word chunk related to a secondtopic keyword.

To create a joke, adding to the topic and the punch word(s) bridge wordsthat incorporate a definition, selected from a database, that pertainsto one of the punch word(s).

To create a joke, starting with a topic, then creating punch word(s)based on that topic, and then adding bridge words that link that topicto the punch word(s) in such a way that the topic, bridge words, andpunch word(s) taken together constitute a natural-sounding unit of text.

To create a joke that may strike a user as humorous, arranging the partsof the joke in this order: topic, bridge words, punch word(s).

To create a joke, adding to the topic sentence and the punch word(s)bridge words that have been generated using machine learning languagemodels that make predictions based on the topic sentence and the punchword(s).

To create a joke using machine learning models, using a language modelpredicting forward from the topic and also a language model predictingbackward from the punch word(s).

To create a joke that may strike a user as more humorous, training themachine learning language models used in the joke generation process onpersonal language data that has been obtained from sources relating tothat particular user.

To create a joke that may strike a user as more humorous, training themachine learning language models used in the joke generation process ona corpus of professionally written, monologue-style jokes.

Ranking jokes by the probability that they would occur in the context ofa large corpus of user-relevant text, with the joke of highestprobability considered to be the best joke.

Ranking jokes by their wordplay score and determining whether thewordplay score for a joke meets a preset threshold that indicatessufficient confidence in the funniness of the joke.

Providing an output to the user, wherein the output is a joke that isoriginal, humorous, natural-sounding, and integrated into the context ofthe input received by the system.

To create a joke based on a topic, linking in a surprising way two topickeywords and words related to them by using reasoning informed bycommonsense knowledge and informed by the anticipated world knowledge,beliefs, and attitudes of the intended audience of the joke to begenerated.

To create a joke based on a topic, utilizing expert-based rules andmachine learning, either individually or in combination.

Implementations of jokes generated using systems and methods disclosedherein include three elements: a topic sentence or topic words; one ormore bridge words or angles; and one or more punch words or punchlines.Other implementations of jokes generated using systems and methodsdisclosed herein include two elements generated in response to receivinga topic sentence: one or more bridge words or angles; and one or morepunch words or punchlines (for example in those implementations thetopic may only be in the topic sentence itself).

General details of the above-described embodiments, and otherembodiments, are given below in the DESCRIPTION, the DRAWINGS, and theCLAIMS.

BRIEF DESCRIPTION OF THE DRAWINGS

Embodiments will be discussed hereafter using reference to the includeddrawings, briefly described below, wherein like designations refer tolike elements:

FIG. 1 illustrates an example of a computing environment that may beused in the systems to implement the methods;

FIG. 2 illustrates a flowchart of an example of a method for generatingjokes implemented using the system of FIG. 14;

FIG. 3 illustrates a flowchart of an example of a method of selecting atopic sentence using the system of FIG. 14;

FIG. 4 illustrates a flowchart of an example of a method for selectingtopic keywords using the system of FIG. 14;

FIG. 5 illustrates a flowchart of an example of a method for generatinga joke of a first type (Type #1) using the system of FIG. 14;

FIG. 6 illustrates a flowchart of an example of a method for calculatinga score for the wordplay between two words or phrases using the systemof FIG. 14;

FIG. 7 illustrates a flowchart of an example of a method for generatinga joke of a second type (Type #2) using the system of FIG. 14;

FIG. 8 illustrates a flowchart of an example of a method used togenerate a joke of a third type (Type #3) and a joke of a fourth type(Type #4) using the system of FIG. 14;

FIG. 9 illustrates a flowchart of a method of ranking and outputting oneof multiple generated jokes using the system of FIG. 14;

FIG. 10 illustrates a flowchart of an example of a machine learningmethod used for generating jokes using the system of FIG. 14;

FIG. 11 illustrates a flowchart of an example of a method of buildingmachine learning language models for use in joke generation methodsusing the system of FIG. 14;

FIG. 12 illustrates a flowchart of an example of a method of usingmachine learning language models to generate bridge candidates using thesystem of FIG. 14;

FIG. 13 illustrates a flowchart of an example of a method of outputtinga best joke generated with machine learning using the system of FIG. 14;

FIG. 14 illustrates a representative example of a system for generatingjokes; and

FIG. 15 illustrates an example of an interface of an end user computingdevice displaying a joke delivered by one or more elements of the systemof FIG. 14.

DESCRIPTION

Implementations/embodiments disclosed herein (including those notexpressly discussed in detail) are not limited to the particularcomponents or procedures described herein. Additional or alternativecomponents, assembly procedures, and/or methods of use consistent withthe intended systems and methods for generating jokes may be utilized inany implementation. This may include any materials, components,sub-components, methods, sub-methods, steps, and so forth.

It is an object of the present invention to provide a novel jokegenerating system and method free from the limitations inherent in theabove-described conventional joke generation systems. Various of thedisclosed embodiments concern systems, methods, and computer-readablestorage media for responding to input obtained from a user via aninteractive device, or from a database, by generating an original,contextually integrated (relevant), and humorous joke that requires nohuman editing. In some embodiments, a user may interact with the systemvia a mobile device, tablet, desktop computer, laptop computer, robot(including social robot), doll, toy, game, telephone, audio/videointerface, chatbot, digital assistant, voice assistant, AI virtualassistant, conversational agent, smart speaker, virtual reality (VR)interface, virtual agent, embodied virtual agent, embodied avatar, smarthome appliance, smart home device, smart environment, smart furniture,voicebot, chatbot, or the like. During the interaction, the system mayreceive a text string as an input. In some implementations this mayinvolve software of the system converting a user's audio input (spokensentence, paragraph, etc.) into a text string and inputting that textstring into a component or element of the system. A topic sentence isselected from the text string and keywords in the topic sentence areidentified and extracted. For each keyword, related words or phrasespreviously stored in a database of the system are identified and variousfeatures are extracted from them. The most promising related words orphrases are linked in various ways to form candidate punch words. Thesystem ranks the candidate punch words and then selects the punch wordsthat rank the highest over a preset threshold. To those punch words andthe topic sentence, the system adds bridge words that are related to thetopic sentence and to the punch words, thus creating an original,contextually integrated, and humorous joke response. The joke responseis then output to the user in audio and/or visual format.

Disclosed embodiments include methods and systems which receive andanalyze textual data and respond with textual jokes. Textual data mayinclude written or audio text. The textual data can be obtained, forexample, from web pages, social media posts, or other documentsavailable over a global computer network such as the Internet. Thetextual data can also be obtained from a speech-to-text converter whichrecognizes speech such as words spoken by a user to an AI virtualassistant, chatbot, robot, smart speaker, and the like and transforms itinto text.

The methods and systems can be implemented using a variety of computingenvironments and devices, including personal computers, servercomputers, mobile devices, smart speakers, database servers, databases,web servers, smart watches, smart glasses, tablets, laptops, atelecommunications network (such as the Internet), etc. Beforedescribing the embodiments in detail, a discussion of example computingenvironments in which the embodiments can be implemented may be useful.FIG. 1 depicts a high-level block diagram of a general-purpose computingdevice suitable for use in performing some of the functions describedherein. As depicted in FIG. 1, the computing device 100 comprises aprocessor 110 (e.g. a CPU); memory 112, e.g. random-access memory (RAM)and/or read-only memory (ROM); software 114 for implementing the method(or portions of the method) described herein for generating one or morejokes; and various additional components 116 which may be implemented ashardware and/or software (such as, by non-limiting example, a receiverand transmitter for communicating with other computing devices of thesystem locally and/or through a telecommunications network, wirelesscommunication elements, a speaker for delivering generated jokes inaudio format, a display for delivering generated jokes in visual format,a text-to-speech synthesizer for converting text to speech, aspeech-to-text converter, user input elements such as a keyboard,keypad, touchscreen, mouse, microphone, and the like). Thedouble-arrowed connectors of FIG. 1 representatively illustrate theindividual elements being able to communicate with one another.

It should be noted that portions of the system and method can beimplemented using software and/or a combination of software andhardware, e.g. using application specific integrated circuits (ASIC),general purpose computers, or any other hardware equivalents. In oneembodiment, the method may be implemented using software 114 forgenerating one or more jokes, the software loaded into memory 112 andexecuted by processor 110 to implement the functions as discussed above.As such, in implementations the method for generating jokes (includingassociated data structures) can be implemented using a non-transitorycomputer-readable storage medium, e.g. RAM memory, magnetic or opticaldrive or diskette, and the like.

Referring now to FIG. 14, a more detailed example of a system 1400 forimplementing joke generation methods (system for generating jokes)(system) is shown. The system includes a plurality of computing devices,each of which may include some or all of the elements describedpreviously with respect to FIG. 1.

For example, computing device (device) 1402 includes interface 1404 andis an administrator device. This device may be used by an administrator(admin) to populate a database 1408, using database server (DB server)1406, with some of the elements of the system as will be describedhereafter, and to make changes to the database elements. In theimplementation shown the admin device is coupled with the DB serverdirectly, though also through a telecommunications network 1410 whichmay be, by non-limiting example, the Internet, though it could also be alocal area network (LAN) in a more localized deployment of the system.The admin device could also communicatively couple with the database/DBserver through a web server 1412, such as by accessing a website usingcredentials. The admin device is shown as a desktop computer but couldbe a laptop, mobile phone, tablet, smart watch, smart speaker, smartglasses, and so forth.

In implementations the admin computer, DB server, database, web server,and the like could all be implemented on a single machine (such as usingvirtual servers on a single machine) but in large network deploymentsthere will more likely be a plurality of cloud-connected server racksused to implement these various elements as the number of users scalesup. For example, AMAZON WEB SERVICES (AWS) server racks may be utilizedto implement the database server, the database, the web server, and soforth so that the number of users may be increased to very largenumbers.

In implementations the system may interact with third partyserver(s)/database(s) 1414 to gather information. As has been describedto some extent above, for example, the system may scour the Internet forcontextual information which will be used in joke generation. This mayinvolve processing online news stories, online encyclopedia articles,online social media content, and so forth (all of which will be storedon third party servers/databases) and storing portions of the same indatabase 1408 to be used in joke generation.

System 1400 shows a number of user devices simultaneouslycommunicatively coupled with the database 1408 via thetelecommunications network, including a personal computer (computer)1416 having a display 1418 and an associated microphone/speaker 1420, anumber of mobile phones 1422-1426 each having a display (1428-1432) andmicrophone/speaker elements (1434-1438), smart glasses 1440 including adisplay 1442 and microphone/speaker elements 1444 (a representativeexample of this would be GOOGLE GLASS), a mobile tablet (tablet) 1446including display 1448 and microphone/speaker elements 1450, a smartwatch 1452 including a display 1454 and microphone/speaker elements1456, a smart speaker 1458 including microphone/speaker elements(representative examples would be GOOGLE HOME, AMAZON ECHO, APPLEHOMEPOD, and the like), a robot 1460 (which may be a humanoid robot,social robot, talking head, avatar, embodied virtual agent, embodiedavatar, or otherwise and which may include microphone/speaker elementsfor user interaction), and any other human interaction device (device)1462 which may include microphone/speaker and other input/outputelements for user interaction (by non-limiting example, user interfacesintegrated in automobiles, trucks, buses, airplanes, telephones,interactive advertising displays, street furniture, Internet of Thingsdevices, wearable technology, virtual receptionist kiosks, and any otherhuman interaction device now known or hereafter discovered/invented).

The system at any given moment may have fewer or more user devicescommunicatively coupled with it, and each type of device may be scaledup to any number of users, so that FIG. 14 is a simplified diagram. Inimplementations, for example, there may be thousands of users or moresimultaneously interacting with the system for joke generation, and thesystem and methods herein may interact with third partysoftware/elements on the user devices (which may involve their ownaccessing of remote servers and databases and the like). For example,GOOGLE ASSISTANT, AMAZON'S ALEXA, or APPLE's SIRI may interact with thesystem so that the jokes generated are then relayed to the user throughthose elements. The system may also have other elements for implementingthe method(s), such as one or more application servers communicativelycoupled with one or more other elements of the system.

While various embodiments of joke generating systems have been describedabove at a high level, these have been presented by way of example only,and not limitation. Thus, the breadth and scope of a preferredembodiment of a joke generating system should not be limited by any ofthe above-described exemplary embodiments.

Following are joke generation methods which can be implemented usingjoke generating systems such as those shown in FIGS. 1 and 14.

FIG. 2 illustrates an example high-level flowchart of a method 200 forgenerating jokes, which jokes may be original, contextually integratedjokes based on text that has been obtained from a source external to theserver(s) of the system. In this exemplary embodiment, the jokes to begenerated comprise three parts, in this order: A) the topic sentence,which is received from a source external to the server(s) of system 1400(for example from end user devices 1416, 1422, 1424, 1426, 1440, 1446,1452, 1458, 1460, 1462, and/or from one or more news websites and/or oneor more other websites); B) bridge words, which smoothly connect thetopic sentence to the punch word or punch words in a way that results ina joke consisting of a natural-sounding sentence or sentences(generated/supplied by one or more of the servers of the system inconjunction with the one or more databases 1408); and C) a punch word orpunch words, which are intended to surprise the user by introducing anincongruity into the joke that suddenly turns out to be harmless andthereby to cause the user to laugh (generated/supplied by one or more ofthe servers of the system in conjunction with the one or more databases1408). At step 210, one or more servers of the system receive text froman external text source, by non-limiting examples from a website or froma human interaction device (such as by non-limiting examples elements1416, 1422, 1424, 1426, 1440, 1446, 1452, 1458, 1460, 1462, one or morenews or other websites (such as by scraping websites), etc.). At step212, the method selects from that text a topic sentence from which thejoke generation process will begin. From that topic sentence, a pair oftopic keywords is selected in step 214; in an alternative embodiment,only one keyword may be selected. From those topic keywords, a punchword or punch words intended to trigger a laugh from the user in thecontext of the joke are created in step 216. In step 218, the punchword(s) are linked together with the topic and with bridge words to formcandidates for jokes; the bridge words are words that the methodgenerates which smoothly connect the topic sentence to the punch word(s)to form a joke that consists of a natural-sounding sentence orsentences. The bridge words may in implementations be called the “angle”and may include characteristics and/or elements of angles disclosed onJoe Toplyn, “Comedy Writing for Late-Night TV,” published by Twenty LaneMedia, LLC (2014), the entirety of which is hereby incorporated hereinby reference (for example pages 68-70 of that publication discussangles). The joke candidates that have been generated are ranked inorder of their humor potential in step 220 and the highest-ranking jokeis determined. Finally, if the highest-ranking joke meets a presetthreshold, it is output to the user in step 222, such as by beingdisplayed visually or output in audio format using interfaces of devices1416, 1422, 1424, 1426, 1440, 1446, 1452, 1458, 1460, 1462. Toillustrate in more detail the method broadly outlined in FIG. 2,detailed examples of block diagrams that describe the various steps inthe method follow.

Topic Sentence Selection

Referring now to FIG. 3, shown is a block diagram of a method 300 toselect a topic sentence from which the joke generation process willbegin. This method may be implemented, by non-limiting example, usingsoftware of the database server and/or software installed on the enduser device. In an exemplary embodiment, this method attempts to obtaininput text at step 312, for example, from text source 310. In anexemplary embodiment, text source 310 may be the output of aspeech-to-text converter such as Google Cloud Speech-to-Text, whichwould be the case if, in an exemplary embodiment, the user were speakingto one of the user interaction devices shown in FIG. 14, though it couldalso be text typed into one of the interaction devices (by non-limitingexample, devices 1416, 1422, 1424, 1426, 1440, 1446, 1452, 1458, 1460,1462, one or more news or other websites, etc.). If at decision step 314it is determined that no text has been input, then the method willattempt again to obtain input text.

Once input text has been obtained, the sentences in the text are listedat step 316 and the first sentence is extracted. The first sentence of atext string is the most likely candidate to be the topic of a jokebecause it is most likely to be the most attention-getting sentence inthe text string.

Decision step 318 determines whether the number of words in the firstsentence of the input text exceeds a preset threshold, for example, 20words (or some other threshold input by the admin using the admincomputer and, for example, stored in the database). A long sentence isan unlikely candidate to be the topic of a joke because it likelycontains too many distracting elements that can divide the attention ofthe joke's intended audience. If at decision step 318 it is determinedthat the first sentence is too long, then the method will attempt toobtain new input text. If at decision step 318 the first sentence isdetermined to be of acceptable length, then at step 320 that sentence isoutput as the topic sentence from which joke generation will beattempted. If the first sentence is too long, in implementations themethod may include reviewing the next listed sentences, in order, untilone below the threshold is found.

By non-limiting example, and referring back to FIG. 14, any individualuser device (mobile phone, tablet, etc.) may have software installed onit that performs some of these functions, such as selecting the topicsentence using the above method, and then the topic sentence may becommunicated to the database server (or another system-coupled server)for other method steps to be performed, such as the remainder of thejoke generation steps, and then the joke is communicated from thedatabase server to the user device using the telecommunications network.In other implementations, the user device may communicate all of thesentences to the database server (or another system-coupled server) andthe server may perform the step of selecting the topic sentence andother method steps to generate the joke and send the joke to the userdevice. In other implementations the database server or othersystem-coupled servers may perform some functions of the joke generationbut the remainder of the joke generation may be done at the user deviceend, for example the database server or other server(s) sending certainelements of a joke to the user device and software installed on the userdevice then incorporating those elements of the joke to form a completedjoke for communication to the user. In other implementations all of thesteps may be performed by the user device using software installed onthe database and using locally-stored elements instead of accessing aremote database. In short, the steps of joke generation described hereinmay be divvied up between software installed on user devices and otherelements of the system of FIG. 14 in any manner to best accomplish themethod. Nevertheless, implementations having a larger overall systemsuch as in FIG. 14 may allow for much larger libraries of informationstored in the database for the system to be able to createcontextualized jokes (such as jokes based on recent news) and may allowthe joke generation methods to be implemented simultaneously for verylarge numbers of users. Furthermore, software at the user-device end orat servers or other elements of the system may be used to implement thevarious logic steps/trees displayed in the Figures, as will beunderstood by the practitioner of ordinary skill in the art.

Any of a variety of known natural language processing packages can beused to extract the first sentence and count the number of words in it.In one exemplary embodiment, the NATURAL LANGUAGE TOOLKIT (NLTK)developed by Steven Bird and Edward Loper of the University ofPennsylvania has sentence and word tokenizers that can accomplish thetasks.

Topic Keyword Selection

Once a topic sentence has been selected and output as in FIG. 3, topickeywords are extracted from it. FIG. 4 shows an exemplary embodiment ofa method 400 for extracting topic keywords. Again, some or all of thesesteps may be performed at the user device level using installed softwareand other aspects may be performed using the DB server and/or otherservers of the system.

One example set of topic keyword candidates consists of nouns, nounphrase chunks, and named entities. Nouns are self-explanatory. Nounphrase chunks are multi-word sequences that correspond to individualnoun phrases. For example, “long-running reality show” is a noun phrasechunk. Named entities are definite noun phrases that refer to specifictypes of entities such as organizations, persons, locations, dates,times, amounts of money, percentages, facilities, and geopoliticalentities. For example, “Mount Everest” is a named entity.

Nouns, noun phrase chunks, and named entities are the most likelycandidates to be useful topic keywords because they are likely to be themost attention-getting words or phrases in the topic sentence. And themost attention-getting words or phrases in the topic sentence are theelements of the topic sentence that are most likely to lead to thegeneration of a funny joke. Other embodiments of this system may alsoinclude verbs, verb phrase chunks, and adjectives in the set ofcandidates for topic keywords.

Word-level tokenization, part-of-speech (POS) tagging, chunking, andnamed entity recognition can be accomplished with any of a number ofnatural language processing tools. One exemplary embodiment will use thetools provided in the NLTK.

Turning to FIG. 4, block 410 represents the topic sentence that wasoutput in step 320. In step 412, the named entities in the topicsentence are extracted using the tools of word-level tokenization, POStagging, chunking, and named entity recognition. At decision step 414 adetermination is made as to whether any of a set of excluding rulesapply to the list of extracted named entities. One example of anexcluding rule involves the number of letters in the named entity. If anamed entity is shorter than two letters, it is excluded in step 416.Another example of an excluding rule involves the presence of the namedentity or its lower-case version on a list of stop words stored in adatabase. Any named entity on the list of stop words is excluded in step416. Any named entity that is not excluded by the excluding rules isadded, in step 418, to the list of candidates for topic keywords. Theexcluding rules may in implementations be set by an admin using theadmin computer. Also, the system may couple with third-party databasesand use third-party excluding rules, and in general the system mayinclude more servers, database servers, application servers, and thelike. For example some of the functionalities described herein (such asselecting topic sentences, applying excluding rules, and other stepsdescribed below) could be handled by one or more application servers ofthe system before querying the database using the database server toobtain elements to generate a joke, which joke may be generated by theapplication server and merely communicated to the user device.

Referring back to stop words, the stop words used by the method includethe most common words in the English language and other words that areunlikely to be useful as topic keywords from which to generate a funnyjoke. An exemplary, but not exhaustive, list of some stop words is asfollows: afternoon; anybody; both; company; dozen; everyone; four; guy;hello; hundred; itself; look; Monday; nowhere; outside; regards; self;sort; thanks; thing; week; whatever; woman; yourself; and so forth. Thestop words may be chosen by the admin using the admin computer and/ormay be chosen using static or dynamic third-party lists of stop wordsaccessed by elements of the system.

In step 420, the nouns in the topic sentence are extracted using thetools of word-level tokenization and POS tagging. Singular and pluralnouns are extracted, including singular and plural proper nouns. Atdecision step 422 a determination is made as to whether any of a set ofexcluding rules apply to the list of extracted nouns. Examples ofexcluding rules are rules that exclude a noun if it is shorter than twoletters or if it or its lower-case version is on the list of stop wordsused by the method. Nouns are also excluded if they are not alphanumericbut are included if they start with “$.” Another reason to exclude anoun is that the noun is present as a separate word in one of the namedentities extracted from the topic sentence. To apply this excludingrule, the named entities extracted from the topic sentence have firstbeen split into separate words. Step 424 excludes any noun excluded bythe excluding rules. Any noun that is not excluded by the excludingrules is added, in step 418, to the list of candidates for topickeywords.

In step 426, the noun phrase chunks in the topic sentence are extractedusing the tools of word-level tokenization and POS tagging. Also used isa chunk grammar consisting of rules that indicate how the topic sentenceshould be chunked. In one exemplary embodiment, the chunk grammar rulessay that a noun phrase chunk should be formed whenever the chunker findsone or more optional adjectives followed by one or two singular orplural nouns, excluding proper nouns. Another rule of the chunk grammarsays that dollar amounts should be extracted as chunks. Using this chunkgrammar, a chunk parser is created using, for example, the RegexpParserchunker in the NLTK. The chunk parser is used to extract noun phrasechunks, including dollar amounts, from the topic sentence.

At decision step 428 a determination is made as to whether any of a setof excluding rules apply to the list of extracted noun phrase chunks.Examples of excluding rules are rules that exclude a noun phrase chunkif it is shorter than two letters, if it or its lower-case version is onthe list of stop words, or if it is present as a separate word or phrasein one of the named entities that were extracted from the topicsentence. Step 430 excludes any noun phrase chunks excluded by theexcluding rules. Any noun phrase chunk that is not excluded by theexcluding rules is added, in step 418, to the list of candidates fortopic keywords and any duplicate candidates are removed from that list.

In implementations, to generate a joke based on the selected topicsentence, the most promising two keywords are chosen from the list ofcandidates for topic keywords. A funny joke may start with a topicsentence that gets the attention of its audience. So the most promisingtwo keywords in the selected topic sentence may be the two mostattention-getting keywords in that sentence. And the two mostattention-getting keywords in the topic sentence may be those twokeywords which are least likely to appear together in a sentence, thatis, the two keywords which an audience would consider to be the leastlikely to share the same context.

To measure how likely it is that two particular words will share acommon context it is possible, in an exemplary embodiment, to measurehow close their word vectors are in an appropriate vector space. Thisvector space can be produced by a machine learning model trained on avery large corpus of audience-relevant text in step 432. An exemplaryembodiment might use GOOGLE's pretrained WORD2VEC model trained onapproximately 100 billion words from a GOOGLE NEWS dataset; that modelincludes word vectors for a vocabulary of 3 million English words andphrases. Other embodiments might use machine learning models that werealso trained on data scraped from online social media; pop culturewebsites; online forums, message boards, and discussion groups; andother data sources that represent the anticipated knowledge, beliefs,and attitudes of the intended audience for the joke or jokes to begenerated. Other embodiments might use machine learning models that areeven more tailored to an individual user because they have also beentrained on that user's most frequently visited websites, websites in theuser's online search and browsing history, social media posts “liked” bythe user, the user's email, the user's communications with an AI virtualassistant, and other personal data sources.

In implementations the first step in selecting two topic keywords fromthe list of candidates for topic keywords is step 434, which filters outcandidates that are not in the vocabulary of the machine learning modelbeing used. Decision step 436 determines whether fewer than twocandidates for topic keywords remain after the filtration process. Iffewer than two candidates remain then the method exits, as shown at step438, and the method will not attempt to generate a joke. If two or morecandidates for topic keywords remain then the similarity, based on themachine learning model being used, of each and every pair of remainingcandidates is calculated in step 440. An exemplary embodiment might usethe “similarity” function of GOOGLE's pretrained WORD2VEC model trainedon GOOGLE NEWS data to calculate the similarity of each pair of wordvectors. An exemplary embodiment would also filter out, in step 442, anypair of candidates with a calculated similarity less than zero; suchpairs of candidates tend to be too dissimilar to be useful as topickeywords.

Whichever two remaining topic keyword candidates are the least similar,as indicated by their pairwise similarity calculation, become the twoselected topic keywords in step 444 and are outputted in step 446. Theseare the two topic keywords that the method will use in attempting togenerate jokes. Because those two topic keywords are the least similarpair, they may be the elements in the topic sentence that are mostlikely to attract an audience's attention. This means that a joke basedon those two topic keywords may be most likely to strike the audience asfunny.

Generation of Joke of Type #1

In implementations, after two topic keywords have been selected as inFIG. 4, a joke of Type #1 is generated from them. FIG. 5 shows anexemplary embodiment of a method 500 of generating a first type of joke(Type #1). Block 510 represents the two topic keywords that wereoutputted in step 446. In step 512, the machine learning model trainedin step 432 is used to list the words that are most similar to eachtopic keyword. That is, for each of the two topic keywords, a list iscreated of the top fifty, for example (which number in implementationsmay be selected by the admin), words that occur most frequently incontexts where the topic keyword appears. An exemplary embodiment mightuse the “most_similar” function of GOOGLE's pretrained WORD2VEC modeltrained on GOOGLE NEWS data to build the list of most similar words,which we'll refer to as related words.

A separate list of related words is compiled for each topic keyword,i.e. for topic keyword A and for topic keyword B. Then each and everyrelated word on the list for topic keyword A, including topic keyword Aitself, is paired with each and every related word on the list for topickeyword B, including topic keyword B itself. The wordplay score of eachpair of words is calculated in step 514. The process of calculating awordplay score is described in detail in FIG. 6. Decision step 516determines whether a pair of related words exists with a wordplay scorethat is better than a certain preset threshold (which may be determinedby the admin in implementations). If such a word pair does not exist,then the method exits, as shown at step 518, and the method will notattempt to generate a joke of Type #1.

If there does exist a pair of related words with a wordplay score thatis better than the preset threshold, then the pair of related words withthe best wordplay score better than the threshold becomes the pair ofpunch words for a joke of Type #1 at step 520. The wordplay between thetwo punch words, because it is unexpected and surprising in the contextof the rest of the joke, will result in the joke's humorous effect.

In step 522 the two punch words, punch word A and punch word B, arearranged in an optimal order that will make the joke read and sound asmuch as possible like natural English speech. To do this, each of thetwo punch words is first tagged with its part of speech using the toolsof word-level tokenization and POS tagging. If punch word A is any typeof adjective, it is placed before punch word B in the joke, and itsrelated topic keyword A is placed before topic keyword B. If punch wordB is any type of adjective, it is placed before punch word A in thejoke, and its related topic keyword B is placed before topic keyword A.If neither punch word is any type of adjective but punch word B beginswith a capital letter, punch word B is placed before punch word A in thejoke, and its related topic keyword B is placed before topic keyword A.

Once the pair of topic keywords and the pair of punch words are arrangedin the optimal order, a bridge is added to the joke. A bridge is astring of words or a template of words that connects the topic sentenceor topic keywords to the punch words in a way that results in anatural-sounding, logical-sounding, syntactically well-formed sentenceor two, completing the joke. By guiding the audience smoothly andefficiently from the topic sentence or topic keywords to the punchwords, the bridge may help set up the audience to be surprised by thepunch words, thereby enhancing the humorous effect of the punch words.

In one exemplary embodiment, a bridge is selected at random in step 524from a list stored in the database. Any one of various random numbergenerators can be used to select a bridge at random from the list in thedatabase.

One exemplary embodiment will draw from a list of bridges like these:“And maybe,” “Oh, I have an idea,” “That reminds me of,” “Oh . . . youmean like,” “Or maybe,” “Is that like,” “Is that the same as,” “What'snext . . . ,” “Then how about,” “I want to see,” “One time I heardabout,” “I suppose that's like,” and so forth. This list of bridges ismerely an example and is not exhaustive.

Once a bridge is selected, the components of the joke of Type #1 areassembled in step 526. First in the joke come the two topic keywords,arranged in their optimal order as detailed above, followed by aquestion mark. Next comes the bridge that was randomly selected from thelist in the database. Last come the two punch words, arranged in theiroptimal order as detailed above. The result of this assembly process isa rough draft of the joke of Type #1.

In step 528 the rough draft of the joke of Type #1 is edited to make thejoke read and sound as much as possible like natural English speech. Ifthe topic keyword in second position is a singular noun, the word “a” or“an” is inserted before the topic keyword in first position. Then thefirst letter of the first word of the joke is capitalized. If the punchword in second position is a singular noun, the word “a” or “an” isinserted before the punch word in first position.

After editing, the completed joke of Type #1 is output in step 530. Inimplementations the wordplay score of the completed joke is the wordplayscore that was calculated in step 520 for the two words related to thetopic keywords that became the punch words of the joke. As describedbelow, the wordplay score of the completed joke is used to compare thefunniness of the joke with that of other jokes and to assess themethod's confidence in the joke.

Calculation of Wordplay Score

This system for generating jokes utilizes a method for calculating ascore for the wordplay between two words or phrases. FIG. 6 shows anexemplary embodiment of a method 600 for calculating a score for thewordplay between two words or phrases.

Wordplay between words or phrases, when it occurs in punch word(s), cancontribute to the humorous effect of a joke because it is surprising inthe context of the joke. Block 610 represents the two words for whichthe wordplay score is to be calculated; call them word A and word B.

A determination is made as to whether any of a set of excluding rulesapply to the pair of words. One example of an excluding rule, atdecision step 612, involves what can be called the beginning of eachword, by non-limiting example the first 75% of each word (in otherimplementations it could be the first 5%, 10%, 15%, 20%, 25%, 30%, 35%,40%, 45%, 50%, 55%, 60%, 65%, 70%, etc., of each word). If word A startswith the beginning of word B or word B starts with the beginning of wordA, that pair of words is determined in step 614 to have no wordplay.Other examples of excluding rules, in steps 616 and 618, involve thelemmas and stems of the two words. If the two words share the same lemmaor the same stem, that pair of words is determined in step 614 to haveno wordplay. Various stemmers and lemmatizers can be used to identifythe stems and lemmas of the words. An exemplary embodiment might use theSNOWBALL STEMMER and the WORDNET LEMMATIZER in the NLTK. The reasons forthese excluding rules are that in implementations for wordplay to have ahumorous effect, it is desirable for the wordplay to elicit surprise inthe audience, and the pairing of two words that are fundamentally thesame word will generally not elicit surprise.

If the pair of words has not been excluded, a wordplay score iscalculated for the pair. In an exemplary embodiment the wordplay scorehas three components. The first component, in step 620, is the editdistance score, which is the edit distance between the two words. Theshorter the edit distance is between the two words, the more surprisingit may be to link the two words together in the joke as punch words andthe funnier the joke may be.

If the two words are both in a pronunciation dictionary, the editdistance is calculated between the first pronunciation listed for eachword in the pronunciation dictionary. If at least one of the words isnot in the pronunciation dictionary, the edit distance between the wordsthemselves is calculated instead and a numerical penalty, bynon-limiting example 0.5 (which in implementations may be set by theadmin and may be any other value, for example 0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9, etc.), is factored into the edit distance score. Thereason for this numerical penalty is that an edit distance calculationbased on how the words are spelled can overstate the degree to which thewords are pronounced in a similar way. If the two words rhyme, anumerical bonus of, say, 1.5 (which in implementations may be set by theadmin and may be any other value, for example 1.1, 1.2, 1.3, 1.4, 1.5,1.6, 1.7, 1.8, 1.9, etc.) is factored into their edit distance score.The reason for this numerical bonus is that words that rhyme may inimplementations have a greater humorous effect than words that do notrhyme, because words that rhyme end unexpectedly with the same sound.The edit distance score, with any penalty and bonus factored in, becomesone component of the wordplay score. To calculate the edit distancescore, an exemplary embodiment might use the CMU Pronouncing Dictionaryin the NLTK and any of various implementations of the Levenshteindistance algorithm.

A second component of the wordplay score in an exemplary embodiment, instep 622, is the stop consonant score. The stop consonant score is thetotal number of stop consonants present in the pair of words as they arespelled, including duplications. Stop consonants are “b,” “d,” “g,” “k,”“p,” and “t.” The presence of stop consonants in a punch line may inimplementations increase the humorous effect of the punch line, so thatthe more stop consonants in the punch words, the funnier the joke maybe. In an alternative embodiment, the stop consonant score may be thetotal number of stop consonant phonemes present in the pair of words asthey are pronounced, including duplications; a pronunciation dictionarysuch as the CMU Pronouncing Dictionary would be used in this embodiment.

A third component of the wordplay score in an exemplary embodiment, instep 624, is the alliteration score. In implementations the alliterationscore is 2 if the first letter of each of the two words is the same inlower case, and the alliteration score rises to 3 if the first twoletters of each of the two words is the same in lower case. Theseparticular points awarded for alliteration are only examples and may bedifferent in other embodiments, and in implementations these may be setby the admin. Alliteration in the punch words, the unexpected repetitionof letters or phonemes, may add to the surprise caused by linking thepunch words in the joke and may increase the humorous effect of thejoke.

In step 626 the wordplay score for the pair of words is calculated andit is output in step 628. In an exemplary embodiment, the wordplay scorefor the pair of words is calculated as their edit distance score, minustheir alliteration score, minus 75% of their stop consonant score. Thefull stop consonant score is not included in the wordplay score inimplementations in order to keep the stop consonant score in balancewith the other two components of the wordplay score. In this embodiment,the lower the wordplay score, the better the wordplay.

Example of Generation of Joke of Type #1

Topic sentence: “Archaeologists in Egypt have discovered a pair of socksmeant to be worn with sandals from 2,000 years ago.”

Topic keywords selected: “Egypt,” “socks”

Related words with the best wordplay score: “Mideast,” “mittens”

Edit distance score: 4.0

Alliteration score: 3.0

Stop consonant score: 4.0

Wordplay score: 4.0−3.0−(0.75*4.0)=−2.0

Maximum acceptable wordplay score to output a joke: 0.0.

Joke output: “Egypt socks? Then how about Mideast mittens?”

Generation of Joke of Type #2

In addition to a joke of Type #1, the two topic keywords selected as inFIG. 4 can also be used to generate a joke of Type #2 if at least one ofthe topic keywords is a string consisting of two or more tokens.Examples of such a string are “parole board,” “United States,” and“Santa Claus.” FIG. 7 shows an exemplary embodiment of a method 700 ofgenerating a second type of joke (Type #2).

Block 710 represents the two topic keywords that were outputted in step446, i.e. topic keyword A and topic keyword B. Decision step 712determines whether both topic keywords consist of only one token. In oneexemplary embodiment, the NLTK has a word tokenizer that will enable thedetermination. If both topic keywords consist of only one token then themethod exits, as shown at step 714, and the method will not attempt togenerate a joke of Type #2.

Decision step 716 determines whether topic keyword A consists of morethan one token. If it does, in step 718 a list is created of the topfifty, for example (which number may in implementations be set by theadmin and may be any number greater than fifty, equal to fifty, or fewerthan fifty), words that occur most frequently in contexts where topickeyword B is used. As in step 512, an exemplary embodiment might use the“most_similar” function of GOOGLE's pretrained WORD2VEC model trained onGOOGLE NEWS data to build the list of most similar words for topickeyword B, which we'll refer to as the topic keyword B related words.Then each of the tokens of topic keyword A is paired in turn with eachtopic keyword B related word and the wordplay score of each pair iscalculated as in FIG. 6. The pairing of the topic keyword A token andthe topic keyword B related word with the best wordplay score isdetermined.

If topic keyword A consists of only one token then topic keyword B mustconsist of more than one token because it has been determined that bothkeywords do not consist of only one token. So if topic keyword A isdetermined in decision step 716 to consist of only one token, in step720 a list is created of the top fifty, for example (which number inimplementations may be set by the admin and may be any number greaterthan, fewer than, or equal to fifty), words that occur most frequentlyin contexts where topic keyword A is used. Again, as an example, the“most_similar” function of GOOGLE's pretrained WORD2VEC model trained onGOOGLE NEWS data may be used to build the list of most similar words fortopic keyword A, which we'll refer to as the topic keyword A relatedwords. Then each of the tokens of topic keyword B is paired in turn witheach topic keyword A related word and the wordplay score of each pair iscalculated as in FIG. 6. The pairing of the topic keyword B token andthe topic keyword A related word with the best wordplay score isdetermined.

Decision step 722 determines whether topic keyword B consists of morethan one token. If topic keyword B does consist of more than one tokenthen the best wordplay score is determined, in step 720, from among thepairings of all tokens of topic keyword B and topic keyword A relatedwords. If topic keyword B consists of only one token then no pairing ofthe token of topic keyword B and the topic keyword A related words isevaluated in decision step 724.

Decision step 724 determines whether any pairing of topic keyword tokenand topic keyword related word has been found in step 718 and step 720that has a wordplay score which is better than a certain presetthreshold, which may be determined by the admin in implementations andmay be set to any desired value. If such a pairing has not been found,then the method exits as shown at step 726 and the method will notattempt to generate a joke of Type #2.

If at least one pairing of topic keyword token and topic keyword relatedword has been found with a wordplay score that is better than a certainpreset threshold, then the pairing with the best wordplay score isdetermined in step 728. The topic keyword containing the token that isin the pairing that yielded the best wordplay score becomes the hoststring for the punch word to be created for a joke of Type #2.

The punch word for the joke of Type #2 is created in step 730. To createthe punch word, the topic keyword related word in the pairing determinedto have the best wordplay score is substituted in the host string forthe token in the host string with which it was determined to have thewordplay.

In step 732 the word that was inserted into the host string in order tocreate the punch word has its first letter capitalized if necessary inorder to match the capitalization of the token it replaced. Matching thecapitalization ensures that the completed joke will read as much aspossible like standard English.

The components of the joke of Type #2 are assembled in step 734. Firstin the joke comes the original host string, i.e. the host string beforethe word was inserted into it to create the punch word. The first letterof the original host string is capitalized because it starts a sentence.A question mark is inserted after the original host string, and then thewords “More like.” Next in the joke comes the punch word that wascreated in step 730. Last come a comma and then the words “am I right?”The result of this assembly process is the completed joke. These arerepresentative examples, and other phrases conveying meaning similar to“More like” and “am I right” could be used in other implementations tocreate a joke of Type #2.

The completed joke of Type #2 is output in step 736. The wordplay scoreof the completed joke is the wordplay score that was calculated in step728 for the word and token that were used to create the punch word. Asdescribed below, the wordplay score of the completed joke is used tocompare the funniness of the joke with that of other jokes and to assessthe method's confidence in the joke.

Example of Generation of Joke of Type #2

Topic sentence: “A new study says eating egg yolks after the age of 40is as bad for you as smoking.”

Topic keywords selected: “egg yolks,” “smoking”

Topic keyword tokens: “egg,” “yolks”

The topic keyword token and topic keyword related word with the bestwordplay score: “yolks,” “smokes”

Edit distance score: 0.5 (This score includes a bonus of 1.5 because thewords rhyme.)

Alliteration score: 0.0

Stop consonant score: 2.0

Wordplay score: 0.5−0.0−(0.75*2.0)=−1.0

Maximum acceptable wordplay score to output a joke: 0.0.

Joke output: “Egg yolks? More like egg smokes, am I right?”

Generation of Joke of Type #3

The two topic keywords selected as in FIG. 4 can also be used togenerate a joke of a third type (Type #3), in which the punch word is aportmanteau word. First a list of related words is compiled for topickeyword A and a separate list of related words is created for topickeyword B. As before, an exemplary embodiment might use the“most_similar” function of GOOGLE's pretrained WORD2VEC model trained onGOOGLE NEWS data to build the lists of related words, which may includenoun-phrase chunks and verb-phrase chunks.

Then the punch word is created by substituting a word related to onetopic keyword for one or more syllables of a word related to the othertopic keyword with which it has adequate wordplay. The adequacy of thewordplay between the word being inserted and the syllable or syllablesit is replacing is determined by calculating their wordplay score asshown in FIG. 6. After the punch word has been assembled, a bridge iscreated and is used to connect the topic sentence to the punch word tocomplete the joke. In implementations the wordplay score of thecompleted joke is the wordplay score associated with the punch word thatis used in the joke.

FIG. 8 shows an exemplary embodiment of a method 800 of creating abridge and outputting a joke of the third type (Type #3). Block 810represents the punch word of the joke of Type #3. Step 812 identifiesthe punch word root, which in implementations is the topic keywordrelated word that comprises at least half of the punch word (though inother implementations it may comprise greater or less than half of thepunch word and may be set by the admin). Step 814 extracts from adatabase or corpus of documents (internal to the system or a third partyprovided database/corpus accessed by the system through the Internet)the punch word root definition, which is a short phrase which definesthe punch word root. To extract the punch word root definition, anexemplary embodiment might use the method described in U.S. Pat. No.7,376,551 B2, “Definition Extraction,” issued May 20, 2008, listing asfirst inventor Kevin R. Powell, the entire disclosure of which isincorporated herein by reference. In implementations step 816 selects abridge template at random from a list stored in a database. Each bridgetemplate assigns the punch word root definition to the punch word.

Here are some non-limiting examples of bridge templates:

“So that means a new [punch word root definition] is [punch word].”

“So how about a new [punch word root definition]: [punch word].”

“Sounds like the new [punch word root definition] is [punch word].”

“They call the new [punch word root definition] [punch word].”

“And maybe a new [punch word root definition] could be [punch word].”

“That's why a new [punch word root definition] is [punch word].”

This list of bridge templates is merely an example and is notexhaustive.

The punch word root definition and punch word are added to the selectedbridge template in step 818, assembling and completing the joke. Thecompleted joke is output in step 820.

Example 1 of Generation of Joke of Type #3

Topic sentence: “For the Olympics, the mayor of Rio wants Pokémon Go tocome to Brazil.”

Topic keywords selected: “Olympics,” “Pokémon Go”

Words related to the topic keywords: “Zika” [the mosquito-borne virus],“Pikachu”

Punch word: “Zikachu”

Punch word root and definition: “Pikachu,” “fictional creature”

Completion of joke with bridge: “So how about a new fictional creature:Zikachu.”

Example 2 of Generation of Joke of Type #3

Topic sentence: “Dow Chemical is turning raw sewage into drinkingwater.”

Topic keywords selected: “sewage,” “drinking water”

Words related to the topic keywords: “poo,” “Poland Spring”

Punch word: “Pooland Spring”

Punch word root and definition: “Poland Spring,” “brand of bottledwater”

Completion of joke with bridge: “They call the new brand of bottledwater Pooland Spring.”

Example 3 of Generation of Joke of Type #3

Topic sentence: “A new website for Disney fans who want to date iscalled Mouse Mingle.”

Topic keywords selected: “Disney,” “date”

Words related to the topic keywords: “Cinderella,” “Tinder”

Punch word: “Tinderella”

Punch word root and definition: “Tinder,” “online dating app”

Completion of joke with bridge: “And maybe a new online dating app couldbe Tinderella.”

Example 4 of Generation of Joke of Type #3

Topic sentence: “America's national forests are being severely damagedby the illegal growing of marijuana.”

Topic keywords selected: “national forests,” “marijuana”

Words related to the topic keywords: “Smokey the Bear,” “toke”

Punch word: “Tokey the Bear”

Punch word root and definition: “Smokey the Bear,” “advertising icon”

Completion of joke with bridge: “That's why a new advertising icon isTokey the Bear.”

Generation of Joke of Type #4

The two topic keywords selected as in FIG. 4 can also be used togenerate a joke of Type #4, in which the punch word is a word chunk suchas a noun phrase chunk. First a list of related words and word chunks iscompiled for topic keyword A and a separate list of related words andword chunks is created for topic keyword B. As before, an exemplaryembodiment might use the “most_similar” function of GOOGLE's pretrainedWORD2VEC model trained on GOOGLE NEWS data to build the lists of relatedwords and word chunks.

Then the punch words are created by substituting a word related to onetopic keyword for one or more words contained in a word chunk related tothe other topic keyword. The word being inserted and the word or wordsit replaces are the same part of speech—nouns or adjectives forexample—and also have adequate wordplay. The adequacy of the wordplaybetween the word being inserted into the word chunk and the word orwords it is replacing is determined by calculating their wordplay scoreas shown in FIG. 6.

After the punch words have been assembled, a bridge is created and isused to connect the topic sentence to the punch words to complete thejoke. FIG. 8 shows an exemplary embodiment of the process of creating abridge and outputting a joke. The punch word root definition and punchword are added to the selected bridge template in step 818, assemblingand completing the joke. The completed joke is output in step 820. Inimplementations the wordplay score of the completed joke is the wordplayscore associated with the punch words that are used in the joke.

Example 1 of Generation of Joke of Type #4

Topic sentence: “Yesterday seven more cases of measles were linked toDisneyland.”

Topic keywords selected: “measles,” “Disneyland”

Words and word chunks related to the topic keywords: “rash,” “SplashMountain”

Punch words: “Rash Mountain”

Punch word root and definition: “Splash Mountain,” “log-flume ride”

Completion of joke with bridge: “So that means a new log-flume ride isRash Mountain.”

Example 2 of Generation of Joke of Type #4

Topic sentence: “Two Wisconsin men were arrested in the theft of 100,000diapers.”

Topic keywords selected: “arrested,” “diapers”

Words and word chunks related to the topic keywords: “petty larceny,”“potty”

Punch words: “potty larceny”

Punch word root and definition: “petty larceny,” “crime”

Completion of joke with bridge: “They call the new crime potty larceny.”

Example 3 of Generation of Joke of Type #4

Topic sentence: “A teacher was fired for leading third graders in theNazi salute.”

Topic keywords selected: “third graders,” “Nazi salute”

Words and word chunks related to the topic keywords: “Duck, Duck,Goose,” “goose-step”

Punch words: “Duck, Duck, Goose-step”

Punch word root and definition: “Duck, Duck, Goose,” “children's game”

Completion of joke with bridge: “Sounds like the new children's game isDuck, Duck, Goose-step.”

Confidence Ranking and Joke Output

In implementations methods for generating jokes may include generatingmultiple jokes using the same keywords and then determining which jokehas the highest ranking and outputting that joke. For example, FIG. 9shows an exemplary embodiment of a process (method) 900 of ranking andoutputting one of multiple jokes generated by the above methods. Block910 represents the jokes of Type #1, Type #2, Type #3, and/or Type #4that were generated. In alternative embodiments, the bridge words forthose jokes may have been generated by a machine learning language modelas shown in FIGS. 10, 11, 12, and 13. Decision step 912 determineswhether the method has created any jokes. If the method has created nojokes then the method exits, as shown at step 914, and the method willnot output a joke. Decision step 916 determines whether the method hascreated only one joke. If the method has created only one joke, step 918tests whether the wordplay score of the joke meets a preset threshold(which in implementations may be set by the admin). If it does, thatmeans the method has sufficient confidence in the joke and the joke isoutput in step 920. If the wordplay score of the joke does not meet thepreset threshold then the method exits, as shown at step 922, and nojoke is output.

In step 924 any jokes of Type #1, Type #2, Type #3, and/or Type #4 areranked according to their wordplay score and the joke that is rankedhighest is selected. Step 926 tests whether the wordplay score of theselected joke meets a preset threshold (which in implementations may beset by the admin). If the wordplay score of the selected joke does notmeet the preset threshold then the method exits, as shown at step 928,and no joke is output. If the wordplay score of the selected joke doesmeet the preset threshold, that means the method has sufficientconfidence in the selected joke and the selected joke is output in step930.

Alternative Embodiment of Method Using Machine Learning

In generating the jokes of Type #1, Type #2, Type #3, and Type #4 asdescribed above, bridges were added that incorporated pre-written wordtemplates or pre-written word strings selected from lists stored in theone or more databases of the system (or stored in remote databasesaccessed by one or more servers of the system through the Internet). Inalternative embodiments, the bridge for jokes of those types will not bein any way pre-written or “canned” but will be generated by a machinelearning language model. A machine learning language model is a naturallanguage processing model which learns to predict the next word in asentence. Bridges generated by a machine learning language model mayallow the jokes generated by the method to be more varied and thereforemore natural-sounding in the context of a lengthy interaction with theuser.

FIG. 10 illustrates an example high-level flowchart of an alternativeembodiment of a method 1000 for generating jokes, which jokes may beoriginal, contextually integrated jokes based on text that has beenobtained from an external source (such as the external sources describedabove, including any user devices and/or any news or other website fromwhich the system may receive/gather information). At step 1010, themethod receives text from a human interaction device and/or from a newssource/website etc.; this process is the same process as that describedfor steps 310 through 314 inclusive. At step 1012, the method selectsfrom that text a topic sentence from which the joke generation processwill begin; this process is the same process as that described for steps316 through 320 inclusive. From that topic sentence, a pair of topickeywords is selected in step 1014; this process is the same process asthat described for steps 410 through 446 inclusive. From those topickeywords, a punch word or punch words which may trigger a laugh from theuser are created in step 1016. These punch words may be created asdescribed for steps 510 through 520 inclusive, as described for steps710 through 730 inclusive, as described for the generation of a joke ofType #3 or of Type #4, or by any other process that creates a surprisingor unexpected word or phrase based on the topic keyword(s) selected froma topic sentence. Decision step 1018 determines whether the wordplayscore of any punch word(s) meets a preset threshold (which inimplementations may be set by the admin). If the wordplay score of noneof the punch word(s) meets the preset threshold then the method exits,as shown in step 1020, and no joke is output. If the wordplay score ofany of the punch word(s) meets the preset threshold then step 1022selects the punch word(s) with the highest-ranked wordplay score.

In step 1024 a machine learning language model is built. The forwardversion of the machine learning language model is used with a forwardbeam search strategy in step 1026 to generate a list of candidates forbridges that may naturally connect the topic sentence to the punchword(s). In step 1028, the topic sentence from step 1012, the list ofbridge candidates from step 1026, and the punch word(s) selected in step1022 are concatenated in that order to form a list of candidates forjokes. In step 1030 the backward version of the machine learninglanguage model is used to select the top, most likely, joke candidatefrom the list of joke candidates compiled in step 1028. The top jokecandidate is output in step 1032. In an exemplary embodiment, the textsource output in step 1032 may then be used as the input to atext-to-speech converter such as, for example, GOOGLE CLOUDTEXT-TO-SPEECH, though in other implementations it could simply bevisually displayed on a user interface of an end user's computingdevice/phone etc. The selected joke may accordingly be delivered inaudio format or visual format to the user.

An alternative embodiment of the process outlined in FIG. 10 may use theforward version of the machine learning language model with a forwardbeam search strategy and the backward version of the machine learninglanguage model with a backward beam search strategy and may alternatelyperform forward beam searches starting with the topic sentence andbackward beam searches starting with the punch word(s), searchingthrough all possible bridge candidates up to a maximum specified bridgelength and determining which bridge candidate maximizes the probabilityof the entire joke. Still another alternative embodiment of the processoutlined in FIG. 10 may use a bidirectional machine learning languagemodel to perform the forward and backward searches.

To illustrate in more detail the process broadly outlined in FIG. 10,detailed examples of block diagrams that describe steps 1024 through1032 of this alternative embodiment of the method follow. FIG. 11 showsan exemplary embodiment of step 1024, which is the process (method) 1100of building the machine learning language model for the method of FIG.10. Again, some or all of the following steps may be performed at theuser device level using installed software and other aspects may beperformed using the DB server and/or other servers of the system. Instep 1110, a general (and in implementations a very large) languagedataset is read into the system. In an exemplary embodiment, thisdataset may be Stephen Merity's WIKITEXT-103 language modeling dataset,which is a collection of over 100 million words extracted from the setof verified Good and Featured articles on the English WIKIPEDIAwebsites. A general and very large dataset such as this may result in anEnglish language model with the world knowledge and the deepunderstanding of grammar, semantics, and other elements of naturallanguage that are useful for the method to generate effective bridgesfor jokes.

Once the very large language dataset is read into the system it isprepared for use in training a universal language model. In step 1112,in an exemplary embodiment, the dataset text is tokenized and adictionary compiled which comprises the vocabulary of the dataset textand the integer index of each word in the vocabulary. In an exemplaryembodiment, this text preprocessing and other tasks of building andtraining the language models and using them to generate jokes may beaccomplished using the neural network library KERAS with the machinelearning library TENSORFLOW as the backend engine. In step 1114, in anexemplary embodiment, the lines of dataset text are turned intosequences of index integers which are then used to create a list ofseparate sequences of varying length to be used in training the models.In step 1116, in an exemplary embodiment, the sequences in the list arepre-padded with zeroes so that they are all the same length as thelongest sequence in the list. And in step 1118, in an exemplaryembodiment, the pre-padded sequences are converted to the form necessaryfor use in training the language model. In an exemplary embodiment, theNUMPY library for PYTHON is used to create an array from the list ofpre-padded sequences and each sequence is split into input and outputelements, where the output element is the last element in the sequenceand is converted to a binary class matrix marking the corresponding wordin the vocabulary.

Now that the training data has been prepared, the universal languagemodel is defined in step 1120. In an exemplary embodiment, the universallanguage model may be a unidirectional recurrent neural network (RNN)such as a long short-term memory network (LSTM). In an exemplaryembodiment, the LSTM model may have an embedding layer, multiple LSTMlayers, and an output layer that uses the softmax activation function,and may also have an argument which determines whether the modelreverses the input sequences. In step 1122, the universal language modelis trained using the prepared training data that has not been reversed.This yields a forward universal language model that can be used topredict the next word in a sentence. In step 1124, the universallanguage model is trained using the prepared training data that has beenreversed. This yields a backward universal language model that can beused to predict the previous word in a sentence.

In an alternative embodiment, instead of building universal languagemodels as described for steps 1110 through 1124 inclusive, where theword embeddings are learned by the models themselves during training,the method may use for universal language models a model or models withpretrained word embeddings that have been learned elsewhere. In anexemplary embodiment, the forward universal language model may have anembedding layer that has been loaded with an embedding matrix computedfrom the GLOVE (Global Vectors for Word Representation) model that hasbeen trained on a year 2014 dump of English WIKIPEDIA websites andGIGAWORD 5; further learning by the forward universal language modelwould then take place on top of that pretrained embedding. In anotherexemplary embodiment, a version of GOOGLE's BERT (Bidirectional EncoderRepresentations from Transformers) that has been pretrained on EnglishWIKIPEDIA websites and BOOKSCORPUS may be used as a forward universallanguage model.

In step 1126 a personalized user language dataset may be obtained, readinto the system, and prepared as in steps 1112 through 1118 inclusivefor use in performing transfer learning with the forward universallanguage model and with the backward universal language model. In anexemplary embodiment, the personalized user language dataset may beobtained by scraping the user's most frequently visited websites,websites in the user's online search and browsing history, social mediaposts “liked” by the user, the user's email, the user's communicationswith an AI virtual assistant, and other personal data sources. In step1128, the personalized user language dataset may be used to refine theforward universal language model, which may have been pretrained in step1122 on the more general language dataset. In this way a personalizedlanguage model may be developed more quickly that can more skillfullypredict words that reflect the user's knowledge base, beliefs, andattitudes. In step 1130, the personalized user language dataset may alsobe used in a similar way to refine the backward universal languagemodel, which may have been pretrained in step 1124 on the more generallanguage dataset.

In step 1132 a joke dataset may be obtained, read into the system, andprepared as in steps 1112 through 1118 inclusive for use in performingadditional transfer learning with the forward personalized languagemodel and with the backward personalized language model. In an exemplaryembodiment, the joke dataset is obtained by scraping websites thataggregate jokes that have been performed in the opening monologues oflate-night comedy/talk television shows. Those monologue jokes may beuseful for training language models to generate jokes because themonologue jokes tend to be relatively short and tend to have structuresthat have been devised by professional comedy writers so as to maximizethe humor potential of the jokes. In step 1134, the joke dataset may beused to fine-tune the forward personalized language model, which wasbuilt in step 1128, for the objective of building a forward joke model.This forward joke model, which may help to generate effective bridgesfor jokes, is output as the forward bridge model in step 1138. In step1136, the joke dataset may also be used to fine-tune the backwardpersonalized language model, which was built in step 1130, for theobjective of building a backward joke model. This backward joke model,which may help to generate effective bridges for jokes, is output as thebackward bridge model in step 1140.

Now that the forward bridge model and the backward bridge model havebeen built, they are used in the joke generation process as outlined ina high-level way in FIG. 10, steps 1026 through 1032 inclusive. Toillustrate step 1026 in more detail, FIG. 12 shows an exemplaryembodiment of the process (method) 1200 of using the forward bridgemodel to generate a list of some of the bridges most likely to follow agiven topic sentence. A forward beam search strategy is used to return alist of the bridges that are predicted to be the most likely to follow agiven topic sentence given a specified beam width and a specifiedmaximum length of the bridge in words. In implementations, the beamwidth and the maximum bridge length in words may be preset or may beinput by the admin in step 1210 using the admin computer. In step 1212,the topic sentence that was output at step 320 by the process shown inFIG. 3 is obtained. In step 1214, the topic sentence and one of thetop-[beam width] bridge candidates are concatenated in the order oftopic sentence first, then bridge candidate; if no bridge candidateshave been identified yet at this point in the process, the topicsentence is not concatenated with anything. In step 1216, the forwardbridge model is used to predict the probability that each word in thedictionary of the model will follow the concatenation of the topicsentence and the current top-[beam width] bridge candidate, if any.Decision step 1218 shows that steps 1214 and 1216 are repeated until thetopic sentence and each of the top-[beam width] bridge candidates havebeen concatenated and the forward bridge model has been used tocalculate the probability that each word in the model dictionary wouldfollow each concatenation of topic sentence and top-[beam width] bridgecandidate.

In step 1220, a list is made of the top-[beam width] most likely nextwords in the bridge as predicted by the forward bridge model, togetherwith the bridge candidates that, when concatenated with the topicsentence, were used to predict those top-[beam width] most likely nextwords. In step 1222, each of the top-[beam width] most likely next wordsin the bridge is concatenated to the end of whichever bridge candidatewas used to predict it, yielding a list of [beam width] new bridgecandidates, which are added to a list of all top bridge candidates.Decision step 1224 shows that steps 1214 through 1222 inclusive arerepeated, each time concatenating the topic sentence with top-[beamwidth] bridge candidates that are one word longer than the previoustop-[beam width] bridge candidates, and each time adding [beam width]new bridge candidates to the list of all top bridge candidates; steps1214 through 1222 inclusive are repeated until the length of each of the[beam width] newest bridge candidates that were added to the list of alltop bridge candidates is the maximum bridge length. The list of all topbridge candidates generated by this process is output in step 1226; thenumber of bridge candidates on that list is equal to the product of thebeam width and the maximum bridge length. The steps shown in FIG. 12 (aswith steps shown in the other drawings) may be performed by one or moreof the aforementioned servers of the system 1400.

Now to illustrate steps 1028 through 1032 in more detail, FIG. 13 showsan exemplary embodiment of the process (method) 1300 of using thebackward bridge model to choose from the list of all top bridgecandidates the best bridge to smoothly connect to the given topicsentence any punch word or punch words that were generated from thetopic sentence using the methods as described earlier. Although inimplementations the topic sentence, the top bridge candidates, and thepunch word(s) may still all be in the form of sequences of indexintegers, “word” will be used at times instead of “index integer”throughout this description as a convenience.

The topic sentence that was output at step 320 by the process shown inFIG. 3 is obtained in step 1310. The list of all top bridge candidatesthat was output at step 1226 by the process shown in FIG. 12 is obtainedin step 1312. And the punch word(s), if any, that were generated andselected by the process outlined in steps 1016 through 1022 inclusiveare obtained in step 1314. In an alternative embodiment, when the punchword(s) have been created in the process of generating a joke of eitherType #3 or Type #4, the associated punch word root may be used as thepunch word(s) in steps 1314 through 1332 inclusive.

In step 1316, the topic sentence, the punch word(s), and each top bridgecandidate in turn are concatenated in the order of topic sentence,bridge candidate, punch word(s), thereby forming a list of jokecandidates. Each joke candidate in that list is reversed in step 1318,forming a list of reversed joke candidates.

In step 1320, one of the reversed joke candidates is taken from the listof reversed joke candidates and prepared for input into the backwardbridge model that was output in step 1140. In an exemplary embodiment,the reversed joke candidate is prepared by pairing each word in thereversed joke candidate with the list of words preceding it in thereversed joke candidate, that list of words having been pre-padded withzeroes, and then converting the two elements of each pair into arraysusing the NUMPY library for PYTHON.

In step 1322, the backward bridge model output in step 1140 is used topredict the conditional probability that each word in the vocabulary ofthe model will be the next word at each position in the reversed jokecandidate, given the words that precede that position in that reversedjoke candidate.

In step 1324, the conditional probability of occurrence of a word thatis actually present in the reversed joke candidate, given the words thatprecede it in the reversed joke candidate, is obtained from theconditional probability predictions made by the backward bridge model instep 1322. In step 1326, the conditional probability obtained for theword in step 1324 is multiplied by the product of the conditionalprobabilities of occurrence of the words that precede it, using thechain rule for probability. The chain rule for probability may berepresented as follows, where P is the probability of joint occurrenceand A₁, . . . , A_(n) is an indexed collection of random variables,words in this case:

P(A _(n) , . . . ,A ₁)=P(A _(n) |A _(n-1) , . . . ,A ₁)*P(A _(n-1) , . .. ,A ₁)

In an exemplary embodiment, the logs of the probabilities are addedinstead of the probabilities being multiplied because the probabilitiesmay be very small. Decision step 1328 shows that steps 1324 and 1326 arerepeated for each word in the reversed joke candidate until theprobability of occurrence of the entire reversed joke candidate iscomputed using the chain rule for probability.

Decision step 1330 shows that steps 1320 through 1328 inclusive arerepeated until the probability of occurrence of each and every reversedjoke candidate has been calculated using the backward bridge model andthe chain rule for probability. In step 1332, the reversed jokecandidate that has the highest probability of occurrence is selected.This is the reversed joke candidate that contains the top bridgecandidate that has been determined to most naturally link the giventopic sentence to the given punch word(s). In step 1334 thishighest-probability reversed joke candidate is reversed back to itsforward state. If a punch word root has been used as the punch word(s)in steps 1314 through 1332 inclusive, the punch word(s) are thensubstituted for the punch word root in the selected joke in step 1334.The selected joke is output in step 1336. In an exemplary embodiment,text source 1336 may then be used as the input to a text-to-speechconverter such as, for example, Google Cloud Text-to-Speech, or it mayalternatively be displayed as text on a user interface of an end user'scomputing device/phone, etc. The selected joke may accordingly bedelivered in audio format or visual format to the user.

The methods disclosed herein are based on using wordplay at the end ofthe joke to link, in a surprising way, two topic keywords and wordsrelated to them and thereby produce a humorous effect. Alternativeimplementations of these methods may link two topic keywords and wordsrelated to them in a surprising way that does not depend on wordplay. Asone example, the surprising link between two topic keywords and thewords related to them could be created using reasoning informed bycommonsense knowledge and by the anticipated knowledge, beliefs, andattitudes of the intended audience of the joke to be generated. Anexemplary embodiment might use the artificial general intelligencetechniques of ALPHABET's DEEPMIND to perform the reasoning tasksrequired to create a surprising link between the two topic keywords andwords related to them. Another implementation might usesequence-to-sequence learning and train a model like, by non-limitingexample, GOOGLE's BERT to convert a topic sentence or sentences into aset of punch words and, optionally, also a set of bridge words, withneither the punch words nor the bridge words depending on wordplay.

The methods disclosed herein may be used for joke generation in avariety of settings. For example, the system in implementations maysimply begin a joke with an introductory sentence (based on some newsheadline or the like) and then deliver the generated joke. Thisimplementation could be used, for example, by a robot or some computingdevice delivering a standup comedy routine, where the routine is notnecessarily affected by any audience input. In other implementations,however, the system may generate jokes in response to user input, forexample a user speaking some sentence or group of sentences or askingsome question either in audio or text format to APPLE's SIRI, GOOGLEASSISTANT, AMAZON'S ALEXA, a chatbot, app, website, or the like, and thevirtual assistant, chatbot, or the like delivering a joke in response(or a joke in addition to the requested information) in audio and/ortext format. (This implementation could also be used for an interactivestandup routine.) An example of this is shown in FIG. 15, in which theuser asks a virtual assistant (such as APPLE's SIRI, AMAZON'S ALEXA, orGOOGLE ASSISTANT) for directions to a marathon and the virtual assistantdelivers a joke related to the request, but also provides a response tothe request for information. In FIG. 15 this is shown as a typedinteraction, the user typing a question and the virtual assistantresponding similarly with a text response—but as indicated above inimplementations such an interaction could be partially or fully in audioformat, such as with the end user asking a question in audio format tothe virtual assistant and/or the virtual assistant delivering the jokeand/or the requested information in audio format (or some combination ofaudio and visual).

In this way the systems and methods could be used as a module to give avirtual assistant or chatbot a more engaging personality, which may makethe user more comfortable when interacting with it. The systems andmethods could also be used to give a social robot a sense of humor,which would make the robot more humanlike and enable the robot to be amore congenial companion, which would help reduce the user's lonelinessand, in that way, may have significant health benefits. The systems andmethods do not need to be used in standup comedy, virtual assistant,chatbot, or social robot settings, however, and may generate jokes forany type of setting. Still another implementation could be ahumor-challenged user having a concealed earpiece and microphone whichallow the user to deliver ad-libbed jokes based on his/her contextualsetting and/or real-time dialogue, the generated jokes, or perhaps onlythe generated punch word(s), being presented to him/her discreetly viathe earpiece. Such systems and methods could be used in all sorts ofsocial gatherings, on dates, in public speaking, and so forth, and mayallow the user to not only have an immediate boost of confidence but,over time, may assist the user in the long-term development of a bettersense of humor.

Any implementation of the joke generating systems may be integrated withan affective sensing system or a sentiment analyzer, as non-limitingexamples the SENTIMENT ANALYSIS feature of GOOGLE CLOUD NATURAL LANGUAGEAPI, or GOOGLE's BERT model used for sentiment analysis, which wouldevaluate the user's emotional state and detect whether joke-making wouldbe acceptable to the user at that particular time. If the affectivesensing system or sentiment analyzer predicts that the user may notreact favorably to a joke at that time, the joke generating system wouldrefrain from outputting to the user whatever joke it may have created.The joke generating systems may also refrain from outputting a joke tothe user if it predicts, based on previous interactions with the user,that the user would not appreciate a joke at that time.

As indicated to some extent above, a system implementing these jokegenerating methods may include one or more or all of the following: anynumber of components communicatively coupled together, including one ormore admin computing devices, one or more admin servers, one or moreapplication servers, one or more database servers, one or moredatabases, one or more third party databases, one or more third partydatabase servers, one or more third party application servers, one ormore third party datasets or libraries, one or more web servers, atelecommunications network, one or more user devices including mobilephones, tablets, desktop computers, laptops, smart watches, smartspeakers, smart glasses, robots, other human interface devices, and thelike; each device/component may have its own computing elementsincluding storage, computer processors, software, and additionalcomponents as described; and the different steps of the methodsdescribed herein may be divvied up between the different components in avariety of ways between the different servers, computing devices, and soforth, as determined by the practitioner of ordinary skill in the art.

In implementations methods for generating jokes as described hereininclude generating jokes that include the following elements organizedin the following order: topic word(s)/keyword(s), bridge word(s), andpunch word(s); or topic(s), bridge word(s), punch word(s). Inimplementations methods and systems disclosed herein may be used for aconversational chatbot with a sense of humor. In implementations thesystems and methods may be used in connection with existingconversational capabilities of a virtual assistant (like APPLE'S SIRI,AMAZON'S ALEXA, or GOOGLE ASSISTANT). In other words, themethods/systems herein may be used as an add-on to the existing virtualassistant and use whatever interface the virtual assistant uses. In suchan embodiment the methods/systems may enable the virtual assistant toad-lib occasional jokes and output them to the user along with all theother output that the virtual assistant would normally be supplying.

In places where the phrase “one of A and B” is used herein, including inthe claims, wherein A and B are elements, the phrase shall have themeaning “A or B.” This shall be extrapolated to as many elements as arerecited in this manner; for example the phrase “one of A, B, and C”shall mean “A, B, or C,” and so forth.

In places where the description above refers to specific embodiments ofsystems and methods for generating jokes, one or more or manymodifications may be made without departing from the spirit and scopethereof. Details of any specific embodiment/implementation/interfacedescribed herein may, wherever possible, be applied to any otherspecific implementation/embodiment/interface described herein.

What is claimed is:
 1. A system for generating jokes, comprising: one ormore databases; one or more servers communicatively coupled with one ormore databases, and; a first computing device communicatively coupledwith at least one of the one or more servers through atelecommunications network; wherein the one or more servers areconfigured to receive text from an external source communicativelycoupled with the one or more servers through the telecommunicationsnetwork and, in response, select one or more topic keywords, generateone or more punch words using words stored in the one or more databaseswhich are related to the one or more topic keywords, use the one or morepunch words to generate one or more jokes, and communicate a signal tothe first computing device; and wherein the first computing device isconfigured to, in response to receiving the signal, display or speak oneof the one or more jokes.
 2. The system of claim 1, wherein the externalsource is the first computing device.
 3. The system of claim 2, whereinthe received text is text typed or spoken to a virtual assistant usingthe first computing device.
 4. The system of claim 1, wherein theexternal source is a third party server and is not the first computingdevice.
 5. The system of claim 1, wherein the one or more servers arefurther configured to select a topic sentence from the received text. 6.The system of claim 1, wherein the one or more servers are furtherconfigured to add one or more bridges to the one or more punch words togenerate the one or more jokes.
 7. The system of claim 1, wherein theone or more servers are further configured to determine a highestranking joke from among the one or more jokes.
 8. A method forgenerating jokes, comprising: providing one or more serverscommunicatively coupled with one or more databases; in response toreceiving text, at the one or more servers through a telecommunicationsnetwork or at a first computing device: selecting one or more topickeywords from the received text using the one or more servers or usingthe first computing device; generating one or more punch words with theone or more servers using words stored in the one or more databaseswhich are related to the one or more topic keywords; generating one ormore jokes with the one or more servers using the one or more punchwords; and communicating a signal to the first computing device throughthe telecommunications network using the one or more servers; and inresponse to receiving the signal at the first computing device,displaying or speaking one of the one or more jokes using the firstcomputing device.
 9. The method of claim 8, wherein the received text isreceived at the one or more servers from the first computing devicethrough the telecommunications network.
 10. The method of claim 9,wherein the received text is text typed or spoken to a virtual assistantusing the first computing device.
 11. The method of claim 8, wherein thereceived text is received at the one or more servers from a third partyserver and not from the first computing device.
 12. The method of claim8, further comprising selecting a topic sentence from the received textusing the one or more servers or the first computing device.
 13. Themethod of claim 8, further comprising adding one or more bridges to theone or more punch words, using the one or more servers, to generate theone or more jokes.
 14. The method of claim 8 further comprising, usingthe one or more servers, determining a highest ranking joke from amongthe one or more jokes.
 15. A method for generating jokes, comprising:providing one or more servers communicatively coupled with one or moredatabases; receiving text at the one or more servers from an externalsource communicatively coupled with the one or more servers through atelecommunications network; in response to receiving the text at the oneor more servers: selecting a topic sentence from the received text usingthe one or more servers; selecting one or more topic keywords of thetopic sentence using the one or more servers; generating one or morepunch words with the one or more servers using words stored in the oneor more databases which are related to the one or more topic keywords;adding one or more bridges to the one or more punch words, using the oneor more servers, to generate one or more jokes; and communicating asignal to a first computing device through the telecommunicationsnetwork using the one or more servers; and in response to receiving thesignal at the first computing device, outputting one of the one or morejokes by one of displaying and speaking the joke using the firstcomputing device, wherein the output joke includes a topic, a bridge,and a punchline.
 16. The method of claim 15, wherein generating the oneor more punch words further comprises selecting a group of words storedin the one or more databases which are related to the one or more topickeywords, sorting the group of words into pairs, and calculating awordplay score for each pair.
 17. The method of claim 15 furthercomprising, using the one or more servers, determining a highest rankingjoke from among the one or more jokes, and further comprising, inresponse to receiving the signal at the first computing device,displaying or speaking the highest ranking joke using the firstcomputing device.
 18. The method of claim 15, wherein the one or moretopic keywords comprise a first topic keyword and a second topickeyword, and wherein the method further comprises, using the one or moreservers, determining whether the first topic keyword is a stringconsisting of two or more tokens and, if so, calculating a wordplayscore for each pairing of at least one of the two or more tokens withone of a plurality of words related to the second topic keyword.
 19. Themethod of claim 15, wherein generating the one or more punch wordsfurther comprises generating a portmanteau word using at least a portionof one of the words related to the one or more topic keywords.
 20. Themethod of claim 15, wherein the one or more topic keywords comprise afirst topic keyword and a second topic keyword, and wherein generatingthe one or more punch words includes selecting a word chunk which isrelated to the first topic keyword and replacing one or more words ofthe word chunk with one or more words that are related to the secondtopic keyword.